package com.tesis_2.Utils;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;

import com.example.tesis_2.R;
import com.tesis_2.MO.MOComentario;
import com.tesis_2.MO.MOReserva;

public class UTReservasArrayAdapter extends  ArrayAdapter<MOReserva>{

	private final Context context;
	private final ArrayList<MOReserva> values;
	
	public UTReservasArrayAdapter(Context context, ArrayList<MOReserva> values ) {
		super(context, R.layout.activity_uimis_reservas, values);
		this.context = context;
		this.values = values;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
		View rowView = inflater.inflate(R.layout.activity_uimis_reservas, parent, false);
		
		((TextView) rowView.findViewById(R.id.txvRestName_mis_reservas)).setText( ((MOReserva) getItem(position)).getRestaurant_name());
		((TextView) rowView.findViewById(R.id.txvLocalName_mis_reservas)).setText( ((MOReserva) getItem(position)).getLocal_name());
		((TextView) rowView.findViewById(R.id.txvHora_mis_reservas)).setText(((MOReserva) getItem(position)).getFormatedRTime());
		((TextView) rowView.findViewById(R.id.txvFecha_mis_reservas)).setText(((MOReserva) getItem(position)).getFormatedRDate());
		
		if ( ((MOReserva)getItem(position)).getStatus() != 2  ) 
		{
			//((Button) rowView.findViewById(R.id.btnCalificar_mis_reservas)).setVisibility(View.INVISIBLE);
			((TextView) rowView.findViewById(R.id.txvCalificar_mis_reservas)).setVisibility(View.INVISIBLE);
		}
		
		
		return rowView;
	}
}
